import log from 'electron-log/renderer'



let IPCONFIG: any = {}
let IS_OPEN_AUTHORITY = false
let VERSION = `1.0.0.000`
let shareWindowSetting = null
let PACS_SETTING = {
  open_auth: true,
  username: 'admin',
  password: '123456',
  PACS_SOURCE: 'orthanc'
}
let dev_check_login_status = false
let toast_base_during_ms = 1000

initIp()

function initIp() {
  const jsonFile = (window as any).electron.ipcRenderer.sendSync('getSysConfig')
  if (!jsonFile) {
    log.error('load config file error')
  }
  const system_server = jsonFile['system_server']

  const ip_4d = jsonFile['ip_4d']
  const box_ip = jsonFile['box_ip']
  const jsonDicomServer = jsonFile['dicom_server']
  const jsonSystemServer = jsonFile['system_server']

  const dicomServer = `http://${jsonDicomServer.ip}:${jsonDicomServer['http_port']}/orthanc/dicom-web`
  // const dicomSocketIoServer = `${jsonDicomServer.ip}:${jsonDicomServer['socket_io_port']}/dicomServer`
  const socketIoServer = `${jsonSystemServer.ip}:${jsonSystemServer['socket_io_port']}/ct`
  console.log(dicomServer)
  IS_OPEN_AUTHORITY = jsonFile['open_authority']
  VERSION = jsonFile['version']
  PACS_SETTING = jsonFile['pacs_setting']
  dev_check_login_status = jsonFile['dev_status']['check_login_status']
  shareWindowSetting = jsonFile["share_window_setting"]
  toast_base_during_ms = jsonFile['toast_base_during_ms'];
  IPCONFIG = {
    baseUrl: `http://${system_server.ip}:${system_server.http_port}`, //常规http地址
    baseWsUrl: `ws://${system_server.ip}:9090/wsCtPanel`, // 常规ws地址，在首页连接来接收一些系统消息：热容量、报警信息等。
    getPicUrlWsUrl: `ws://${system_server.ip}:9091/wsCtPanel`, // 接收图片地址ws地址，好像只在scoutView页面用到了
    get4dWsUrl: `ws://${ip_4d}:9093/ws`, // 4d ws
    get4dEvent: `ws://${system_server.ip}:9092/wsCtPanel`, // 4d 信号

    cameraUrl: `http://${system_server.ip}:8888`,
    cameraWs: `ws://${system_server.ip}:9999`,
    base4dUrl: `http://${ip_4d}:9093`,
    BOX_IP: box_ip,
    dicomServer,
    socketIoServer
    // dicomSocketIoServer,
    // systemSocketIoServer
  }
}


const AUTHORITY = {
  TRANSPORT: {
    transport: '1-1'
  },
  SCAN: {
    scan: '2-1',
    delete: '2-2',
    exceedDose: '2-3'
  },
  SERVICE: {
    service: '3',
    bulbHeating: '3-1',
    airCorrecting: '3-2',
    normalQA: '3-3',
    authManage: '3-4',
    inspectionReport: '3-5',
    manualScan: '3-6',
    orgManage: '3-7',
    dicomManage: '3-8',
    logManage: '3-9',
    diskManage: '3-10',
    remoteUpdate: '3-11',
    serviceReport: '3-12',
    performanceEvaluation: '3-13',
    viewerSetting: '3-14',
    hardwareTest: '3-15',
    systemStatistics: '3-16',
    batteryInfo: '3-17',
    processConfig: '3-18',
    systemSetting: '3-19',
    auditLogManage: '3-20'
  }
}


export {
  IPCONFIG,
  AUTHORITY,
  IS_OPEN_AUTHORITY,
  VERSION,
  PACS_SETTING,
  dev_check_login_status,
  shareWindowSetting,
  toast_base_during_ms
}
